<?php
/* @var $this TeachingController */
/* @var $model Teaching */

$this->breadcrumbs=array(
	'教学资源管理'=>array('admin'),
	$model->title,
);

$this->menu=array(
	array('label'=>'返回教学资源管理', 'url'=>array('admin')),
	array('label'=>'创建教学资源', 'url'=>array('create')),
	array('label'=>'更新当前教学资源', 'url'=>array('update', 'id'=>$model->teaching_id)),
	array('label'=>'删除当前教学资源', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->teaching_id),'confirm'=>'Are you sure you want to delete this item?')),
);
?>

<h1>当前教学资源 # <?php echo $model->title; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'teaching_id',
		'title',
		'user.user_name',
		'create_date',
		array(
            'name'=>'status',
            'value'=>$model->getType(),
        ),
		array(
            'name'=>'active',
            'value'=>$model->getActive(),
        ),
	),
)); ?>
<h4>教学资源描述</h4>
 <?php echo $model->description; ?>
<hr/>
<h4>资源列表</h4>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'teaching-grid',
	'dataProvider'=>$dataProvider,
	'columns'=>array(
		'title',
        'content',
		array(
            'class'=>'CButtonColumn',
            'template'=>'{delete}',
            'buttons'=>array(
                'delete' => array(
                    'label'=>'View Project',
                    'url'=> 'Yii::app()->createURL("admin/teaching/deleteResources", array("rid"=>$data->resources_id))',
                ),
            ),
			'header'=>'操作',
        ),
    ),
)); ?>
<button class="btn btn-default btn-lg" data-toggle="modal" data-target="#myModal">
  上传资源
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Choose File</h4>
      </div>
      <div class="modal-body">
        <?php
            $form=$this->beginWidget('CActiveForm', array(
                'id'=>'add-form',
                'enableClientValidation'=>true,
                'clientOptions'=>array( 'validateOnSubmit'=>true,),
                'htmlOptions'=>array('enctype'=>'multipart/form-data'),
            ));
        ?>
          <div class="form-group">
            <label><?php echo yii::t('models/Resources','Title');?>: </label>
            <input type="text" name="title" class="form-control info"></input>
          </div>
          <div class="form-group">
            <label><?php echo yii::t('models/Resources','Content');?>: </label>
            <textarea id="resourceContent" name="content">
            </textarea>
     	    <script type="text/javascript">
            var editor = new UE.ui.Editor({
                  toolbars:[['undo','redo','RowSpacing','FontFamily','FontSize','insertimage', 'emotion', 'scrawl']]
            });
			    editor.render("resourceContent");
            </script>
          </div>
        <?php echo CHtml::activeFileField($modelFile, 'file'); ?>
        <?php echo $form->error($modelFile,'file');?>
        <?php echo CHtml::button('Upload', array('submit' => array('teaching/view/'.$model->teaching_id))); ?>
        <?php $this->endWidget(); ?>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
